package com.aaa.controller;

import com.aaa.entity.Staff;
import com.aaa.service.MenuService;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Arrays;

/**
 * @program: keyboard
 * @description:
 * @author: 闫克起2
 * @create: 2024-03-15 17:08
 **/
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;
    @Autowired
    private HttpSession session;
    @GetMapping("/leftMenu")
    public Result leftMenu(){
        Staff staff = (Staff) session.getAttribute("staff");
        Result result = menuService.findByStaffId(staff.getId());
        return result;
    }

    @GetMapping("getByRoleId")
    public Result getByRoleId(Integer roleId){
        return menuService.findByRoleId(roleId);
    }

    @GetMapping("/confirmUpdate")
    public Result confirmUpdate(Integer roleId,Integer[] menuIds){

        return menuService.confirmUpdate(roleId,menuIds);
    }
}
